#ifndef ZNETLIBBIGDATATEST_SERVER_H
#define ZNETLIBBIGDATATEST_SERVER_H

#include <QtGui/QMainWindow>
#include "ui_znetlibbigdatatest_server.h"
#include "../ZNetLib/ZProcessor/ZProcessorMgr.h"
#include "../ZTcpNetLib/Package/ZPackReactor.h"
#include "../ZTcpNetLib/ZSocket/ZTcpServerSocket.h"

class ZFilePackReactor : public ZPackReactor
{
public:
	ZFilePackReactor(QLabel* pLabel);

public:
	virtual void DealPackage(const ZPackage& pack) const;
	virtual	const QString GetCarePackType();

private:
	QLabel*		m_pLabel;
};

class ZTcpFilePackReactor : public ZTcpPackReactor
{
public:
	ZTcpFilePackReactor(QLabel* pLabel);

public:
	virtual void DealPackage(const ZPackageBase& pack, QTcpSocket* pDealSock) const;
	virtual	const QString GetCarePackType();

private:
	QLabel*		m_pLabel;
};

class ZTcpStrPackReactor : public ZTcpPackReactor
{
public:
	ZTcpStrPackReactor(QWidget* pWidget);

public:
	virtual void DealPackage(const ZPackageBase& pack, QTcpSocket* pDealSock) const;
	virtual	const QString GetCarePackType();

private:
	QWidget*	m_pWidget;
};

class ZTcpServerSocket_Test : public ZTcpServerSocket
{
public:
	ZTcpServerSocket_Test(ZTcpPackReactorMgr* pReactorMgr);

public:
	void SetInfoWidget(QLabel* pInfoLabel) { m_pInfoLabel = pInfoLabel; }

protected:
	virtual void OnAcceptNewConnection(QTcpSocket* pNewConSock);
	virtual void OnDisConnectedConnection(QTcpSocket* pNewConSock);

private:
	void UpdateInfoLabel();

private:
	QLabel*		m_pInfoLabel;
	int			m_iCurConnectCount;
	int			m_iMaxConnectCount;
};

class ZNetLibBigDataTest_Server : public QMainWindow
{
	Q_OBJECT

public:
	ZNetLibBigDataTest_Server(QWidget *parent = 0, Qt::WFlags flags = 0);
	~ZNetLibBigDataTest_Server();

private slots:
	void _onSendBtnClick();

private:
	Ui::ZNetLibBigDataTest_ServerClass ui;

private:
	ZProcessorMgr m_processorMgr;
	ZTcpPackReactorMgr	m_tcpReactorMgr;
	ZTcpServerSocket_Test	m_serverSock;
};

#endif // ZNETLIBBIGDATATEST_SERVER_H
